package edu.ucsd.cse135.gas.action.reviewer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import edu.ucsd.cse135.gas.bean.reviewer.ReviewBean;
import edu.ucsd.cse135.gas.logic.applicant.Applicant;
import edu.ucsd.cse135.gas.logic.reviewer.ReviewerFunctions;
import edu.ucsd.cse135.gas.resources.Constants;

public class StoreReviewerAction extends Action {

	public StoreReviewerAction() {
		super();
	}
	
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
		
		ReviewBean reviewBean = (ReviewBean)form;
		Applicant applicant = (Applicant)request.getSession().getAttribute("applicant");
		ReviewBean grading = (ReviewBean)request.getSession().getAttribute("grading");
		
		ReviewerFunctions.storeReviewer(reviewBean.getReviewer(), applicant.getMail(), grading.getReviewer(), grading.getGrade(), grading.getComment());
		
		return mapping.findForward(Constants.SUCCESS);
	}	
}